<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.roadmap.struts.action.ActionConst"%>
<%@ page import="com.roadmap.common.RdcResourceBundle" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String user_ssn_id = (String)request.getAttribute(ActionConst.Aspirant_Id_In_Session);
String user_req_id = request.getParameter(ActionConst.Aspirant_Id_In_Request);
if(user_req_id == null){
	user_req_id = user_ssn_id;
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/> 
<link href="res/css/layout.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/life.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/widget.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="res/js/util.js"></script>
<script type="text/javascript" src="res/js/widget.js"></script>
<script type="text/javascript" src="res/js/func.js"></script>
<title><bean:write name="<%=ActionConst.Aspirant_Name_In_Request %>"/>的梦想 | <%=RdcResourceBundle.COMPANY_NAME %></title>

</head>

<body>
	<jsp:include page="/admin/myheader.jsp"></jsp:include>
	
	<!-- define the frame for logging on-->
	<div class="mainbody"><div class="manager">
	<jsp:include page="/admin/life/nav_btns.jsp"/>
	
	<!-- middle part: content -->
	<div class="middle-part">
		<div class="section" style="border-bottom: 1px solid #E78F28;">
			<div class="title-sp">
				<a href="aspirant.do?uid=<%=user_req_id %>#v=behav"><bean:write name="<%=ActionConst.Aspirant_Name_In_Request %>"/></a>的梦想
			</div>
			
			<logic:present name="<%=ActionConst.Visitor_Is_Owner %>">
			<div class="float-right"><a href="javascript:goToEdit();"><img src="res/images/logo/edit_10.png" title="编辑"/></a></div>	
			</logic:present>				
		</div>
							
		<div id="view-sec" class="section">
			<table class="vision-table" cellspacing="10px">
				<tr><td class="text-td"><span class="field-title"><bean:write name="<%=ActionConst.Aspirant_Name_In_Request %>"/>有一个梦想:</span></td></tr>
				<tr><td class="input-td">
					<p id="view-dream" class="text-dream-faith"><bean:write name="lifemapForm" property="dream"/></p>
				</td></tr>
				<tr><td class="text-td"><span class="field-title">这个梦想的内容是:</span></td></tr>
				<tr><td class="input-td">
					<p id="view-dreamContent" class="text-content"><bean:write name="lifemapForm" property="dreamContent"/></p>
				</td></tr>
				<tr><td class="text-td"><span class="field-title"><bean:write name="<%=ActionConst.Aspirant_Name_In_Request %>"/>的信念是:</span></td></tr>
				<tr><td class="input-td">
					<p id="view-faith" class="text-dream-faith"><bean:write name="lifemapForm" property="faith"/></p>
				</td></tr>
			</table>
		</div>
		
		<logic:present name="<%=ActionConst.Visitor_Is_Owner %>">
		<!-- this part can only be viewed by the information owner -->
		<div id="edit-sec" class="section" style="display:none;">
			<html:form action="/vision">
			 	<input type="hidden" name="act" value="view"/>
			 	<input type="hidden" name="<%=ActionConst.Aspirant_Id_In_Request %>" value="<%=user_req_id %>"/>
				<html:hidden property="mapId"/>				
				<table class="vision-table" cellspacing="10px">
					<tr><td class="text-td"><bean:write name="<%=ActionConst.Aspirant_Name_In_Request %>"/>有一个梦想:</td></tr>
					<tr><td class="input-td">
						<html:textarea property="dream" styleClass="dream-faith" tabindex="2" title="梦想主题(1~80)"/>
					</td></tr>
					<tr><td class="text-td">这个梦想的内容是:</td></tr>
					<tr><td class="input-td">
						<html:textarea property="dreamContent" styleClass="dream-content" tabindex="3" title="梦想内容(1~200)"/>
					</td></tr>
					<tr><td class="text-td"><bean:write name="<%=ActionConst.Aspirant_Name_In_Request %>"/>的信念是:</td></tr>
					<tr><td class="input-td">
						<html:textarea property="faith" styleClass="dream-faith" tabindex="4" title="信念(1~80)"/>
					</td></tr>
					<tr><td align="center"><html:button property="saveBtn" styleClass="confirmBtn" value="保存"
											tabindex="5" onclick="saveForm();"/>
							<html:button property="cancelBtn" styleClass="cancelBtn" value="取消"
											tabindex="6" onclick="goToView();"/></td>
					</tr>
				</table>			
			</html:form>
		</div>
		</logic:present>
	</div>
	
	<!-- right part: -->
	<div class="right-part">
	</div>
	
	</div>
	
	<div class="clear-div"></div>
	</div>
	
	<jsp:include page="/res/jsp/footer.jsp"></jsp:include>

<script type="text/javascript">
	// var v=<%=(String)request.getParameter("act")%>;
	// alert(v);
	window.onload = function(){
		goToView();
	}
		
	function goToView(){
		RDC.gui.display("view-title");
		RDC.gui.display("view-sec");
		RDC.gui.display("editBtn");
		
		RDC.gui.hide("edit-title");
		RDC.gui.hide("edit-sec");
		
	}
	
	function goToEdit(){
		RDC.gui.hide("view-title");
		RDC.gui.hide("view-sec");
		RDC.gui.hide("editBtn");
		
		RDC.gui.display("edit-title");
		RDC.gui.display("edit-sec");
	
		setDataToEdit();
		
		$("dream").focus();
	}
	
	function setDataToEdit(){
		$("dream").value=$("view-dream").innerHTML;
		$("dreamContent").value=$("view-dreamContent").innerHTML;
		$("faith").value=$("view-faith").innerHTML;
	}
		
	function set(target){
		document.forms[0].act.value=target;
	}
	
	function checkForm(){	
		if(!checkDream() || !checkDreamContent() || !checkFaith())
			return false;
		else 
			return true;	
	}
	
	function saveForm(){
		if(checkForm()){
			RDC.gui.enable("saveBtn");
			RDC.gui.enable("cancelBtn");
			set("edit");
			document.forms[0].submit();			
		}
	}
	
	function checkDream(){
		var str=$("dream").value;
		if(!RDC.util.verifyText(str, 1, 80)){
			PromptDialog.show("梦想字符总数在1~80之间");
			$("dream").focus();
			return false;
		}
		return true;
	}	
	
	function checkDreamContent(){
		var str=$("dreamContent").value;
		if(!RDC.util.verifyText(str, 1, 200)){
			PromptDialog.show("梦想内容字符总数在1~200之间");
			$("dreamContent").focus();
			return false;
		}
		return true;
	}	
	
	function checkFaith(){
		var str=$("faith").value;
		if(!RDC.util.verifyText(str, 1, 80)){
			PromptDialog.show("信念字符总数在1~80之间");
			$("faith").focus();
			return false;
		}
		return true;
	}	
		

</script>

</body>

</html>
